<?php
/**
 * YOS News Crawler Component
 *
 * @package		yos_news_crawler
 * @subpackage	CMS
 * @link		http://yopensource.com
 * @author		yopensource
 * @copyright 	yopensource (yopensource@gmail.com)
 * @license		Commercial
 */

// no direct access
defined('_JEXEC') or die('Restricted access');


class YOS_Joomla_article extends JObject {
	//object article
	private $_articleID;
	
	// dbo
	private $_dbo=null;
	
	public $msg=null;
	
	public function __construct($articleID)
	{
		$this->_articleID = $articleID;
		if(!$this->getDBO())
		{
			return $this->msg;
		}		
	}
	function getDBO()
	{
		$this->_dbo=JFactory::getDBO();		
		return $this->_dbo;
	}	
	public function deleteArticle()
	{
		
		JArrayHelper::toInteger($cid);

		if (count($this->_articleID) < 1) {
			$this->msg =  JText::_('Select an item to delete');			
			return false;		
		}

		// Removed content gets put in the trash [state = -2] and ordering is always set to 0
		$state		= '-2';
		$ordering	= '0';
		
		// Update articles in the database
		$query = 'UPDATE #__content' .
				' SET state = '.(int) $state .
				', ordering = '.(int) $ordering .
				', checked_out = 0, checked_out_time = '.$this->_dbo->Quote($nullDate).
				' WHERE id = '. $this->_articleID;
		$this->_dbo->setQuery($query);
		if (!$this->_dbo->query())
		{
			$this->msg=$this->_dbo->getErrorMsg();
			return false;
		}
		$cache = & JFactory::getCache('com_content');
		$cache->clean();
		return true;
	}
}